//
//  YXMineMenuView.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/21.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXMineMenuView.h"

@implementation YXMineMenuView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self createBtnUI];

    }
    return self;
}

- (void)createBtnUI {
    NSArray *arr = @[@"我的工单",@"我的论坛"];
    for (int i = 0; i < 2; i ++) {
        UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        btn.frame = CGRectMake(self.frame.size.width/2*i, 0, self.frame.size.width/2, 70);
        //        btn.backgroundColor = [UIColor randomColor];
        [btn setTitle:arr[i] forState:(UIControlStateNormal)];
        [btn setTitleColor:color_textOne forState:(UIControlStateNormal)];
        btn.titleLabel.font = [UIFont systemFontOfSize:16];
        btn.titleEdgeInsets = UIEdgeInsetsMake(30, 0, 0, 0);
        btn.tag = 200 + i;
        [btn addTarget:self action:@selector(mineMenuAction:) forControlEvents:(UIControlEventTouchUpInside)];
        [self addSubview:btn];
        
        UILabel *lab = [UILabel setLabelWithText:@"0" fontSize:22 color:color_globalColor];
        lab.frame = CGRectMake(self.frame.size.width/2 * i + self.frame.size.width/2/2-15, self.frame.size.height - 55, 30, 20);
        lab.textAlignment = NSTextAlignmentCenter;
        [self addSubview:lab];
    }
    
    for (int i = 0 ; i < 2; i ++) {
        // 分割线
        if (i > 0 && self.frame.size.height > 16) {
            UIView *line = [[UIView alloc] initWithFrame:(CGRectMake(300 / 2 *i, 18, 1, self.frame.size.height - 36))];
            line.backgroundColor = color_lineColor;
            [self addSubview:line];
        }
    }
    
}

- (void)mineMenuAction:(UIButton *)sender {
    if (self.clickMenuBtnBlock) {
        self.clickMenuBtnBlock(sender.tag - 200);
    }
    
}


@end
